import 'package:flutter/material.dart';
import 'package:gsy_flutter_app/common/style/GSYStyle.dart';

/// 作者: Tao
/// 日期: 2024/1/17
/// 时间: 10:07
/// 描述: 自定义button控件
class GSYFlexButton extends StatelessWidget {
  ///文字内容
  final String text;

  ///背景颜色
  final Color color;

  ///文字颜色
  final Color textColor;

  ///回调监听
  final VoidCallback onPress;

  const GSYFlexButton(
      {Key? key,
      required this.text,
      this.color = const Color(GSYColors.primaryValue),
      this.textColor = const Color(GSYColors.textWhite),
      required this.onPress})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
            child: ElevatedButton(
          onPressed: onPress,
          style: TextButton.styleFrom(
              backgroundColor: color,
              padding: const EdgeInsets.only(
                  left: 20, top: 10, right: 20, bottom: 10)),
          child: Text(
            text,
            style: TextStyle(fontSize: 20, color: textColor),
            textAlign: TextAlign.center,
            overflow: TextOverflow.ellipsis,
          ),
        ))
      ],
    );
  }
}
